package com.youtills.resource;

import com.youtills.core.lang.ObjectUtil;

/**
 * TODO - !!!doc me!!!
 *
 * @author ravi.chiluveru
 * @since 23.0 (8/15/14)
 */
public final class ResourceRelationshipValue<L extends Resource, R extends Resource> {

    private final ResourceRelationship<L, R> resourceRelationship;
    private final Long resourceType;
    private final Long resourceId;
    private String orderValue;

    public ResourceRelationshipValue(ResourceRelationship<L, R> resourceRelationship, Long resourceType, Long resourceId) {
        this(resourceRelationship, resourceType, resourceId, null);
    }
    public ResourceRelationshipValue(ResourceRelationship<L, R> resourceRelationship, Long resourceType, Long resourceId, String orderValue) {
        this.resourceRelationship = resourceRelationship;
        this.resourceType = resourceType;
        this.resourceId = resourceId;
        this.orderValue = orderValue;
    }

    public ResourceRelationship<L, R> getResourceRelationship() {
        return resourceRelationship;
    }

    public Long getResourceType() {
        return resourceType;
    }

    public Long getResourceId() {
        return resourceId;
    }

    public String getOrderValue() {
        return orderValue;
    }

    public void setOrderValue(String orderValue) {
        this.orderValue = orderValue;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof ResourceRelationshipValue) {
            ResourceRelationshipValue o = (ResourceRelationshipValue)obj;
            return ObjectUtil.areEquals(resourceRelationship, o.resourceRelationship) && ObjectUtil.areEquals(resourceId, o.resourceId) && ObjectUtil.areEquals(orderValue, o.orderValue);
        }
        return false;

    }
}
